package app.mvc.view
{
	import alternativa.gui.alternativagui;
	import alternativa.gui.keyboard.IKeyFilter;
	import alternativa.gui.keyboard.IKeyboardListener;
	import alternativa.gui.keyboard.KeyFiltersConfig;
	import alternativa.gui.keyboard.KeyboardManager;
	
	import app.mvc.Notifications;
	import app.mvc.model.keyboards.AppMainLayerKeyFilter;
	import app.mvc.view.layers.BackgroundLayer;
	import app.mvc.view.layers.ObjectsLayer;
	import app.mvc.view.layers.OperationsLayer;
	
	import flash.display.Sprite;
	import flash.events.KeyboardEvent;
	import flash.ui.Keyboard;
	
	import globals.Global;
	
	import org.puremvc.as3.patterns.facade.Facade;
	
	use namespace alternativagui;
	
	/**
	 * 主面板
	 * @author XiLing
	 */
	public class AppMainView extends Sprite  implements IKeyboardListener
	{
		public var guiObjectLayer:Sprite= new Sprite();
		public var guiMouseHintLayer:Sprite= new Sprite();

		//背景层
		public var backgroundLayer:BackgroundLayer=null;
		//物件层
		public var objectsLayer:ObjectsLayer=null;
		//工具操作层
		public var operationsLayer:OperationsLayer=null;
		
		//逻辑
		private var keyConfig:KeyFiltersConfig;
		private var keyFilter:AppMainLayerKeyFilter;
		
		public function AppMainView()
		{
			super();			
		}
		
		public function init():void
		{

			guiObjectLayer.mouseEnabled = false;
			guiObjectLayer.tabEnabled = false;
			addChild(guiObjectLayer);

			guiMouseHintLayer.mouseChildren = guiMouseHintLayer.mouseEnabled = false;
			guiMouseHintLayer.tabEnabled = false;
			addChild(guiMouseHintLayer);
			
			backgroundLayer = new BackgroundLayer();
			guiObjectLayer.addChild(backgroundLayer);
			
			objectsLayer = new ObjectsLayer();
			guiObjectLayer.addChild(objectsLayer);
			
			operationsLayer = new OperationsLayer();
			guiObjectLayer.addChild(operationsLayer);
			
			//键盘监听
			keyConfig = new KeyFiltersConfig();
			keyFilter = new AppMainLayerKeyFilter();
			keyConfig.addKeyDownFilter(keyFilter,"onKeyDown");
			keyConfig.bindKeyDownAction("onKeyDown",keyFilter,keyFilter.onKeyDown);
			KeyboardManager.addKeyboardListener(this);
		}
		
		public function get keyFiltersConfig():KeyFiltersConfig
		{
			// TODO Auto Generated method stub
			return keyConfig;
		}
	}
}